package com.Home
{
	import com.*;
	import com.Engine.*;
	import com.Packet.*;
	import com.UI.*;
	
	import flash.display.*;
	import flash.events.*;
	import flash.external.*;
	import flash.filters.*;
	import flash.geom.*;
	import flash.system.*;
	import flash.text.*;
	import flash.ui.*;
	import flash.utils.*;
	
	import org.aswing.*;
	import org.aswing.border.*;
	import org.aswing.border.EmptyBorder;
	import org.aswing.colorchooser.*;
	import org.aswing.dnd.*;
	import org.aswing.event.*;
	import org.aswing.ext.*;
	import org.aswing.geom.*;
	import org.aswing.tree.AbstractLayoutCache;
	public class FrameHomeBuilding9Equip extends FrameHomeBuilding
	{
		private var btn_equip_levelup:JButton;
		private var btn_equip_compose:JButton;
		public function FrameHomeBuilding9Equip()
		{
			btn_equip_levelup = new JButton();
			btn_equip_levelup.setSize(new IntDimension(72, 23));
			btn_equip_levelup.setPreferredSize(new IntDimension(72, 23));
			btn_equip_levelup.setText("装备升级");
			
			btn_equip_compose = new JButton();
			btn_equip_compose.setSize(new IntDimension(72, 23));
			btn_equip_compose.setPreferredSize(new IntDimension(72, 23));
			btn_equip_compose.setText("装备合成");
			
			panelButtons.append(btn_equip_levelup);
			panelButtons.append(btn_equip_compose);
			
			btn_equip_compose.wrapSimpleButton(Client.getUIElement("btn_4") as SimpleButton);
			btn_equip_levelup.wrapSimpleButton(Client.getUIElement("btn_4") as SimpleButton);
			
			btn_equip_compose.setBackground(ASColor.GRAY);
			btn_equip_levelup.setBackground(ASColor.GRAY);
			
			var filter:GlowFilter;
			var font:ASFont = new ASFont("宋体", 14, false, false, false, false);
			filter = new GlowFilter(0x000000, 1, 2, 2, 5);
			
			btn_equip_levelup.setFont(font);
			btn_equip_levelup.setForeground(ASColor.WHITE);
			btn_equip_levelup.setTextFilters(new Array(filter));
			
			btn_equip_compose.setFont(font);
			btn_equip_compose.setForeground(ASColor.WHITE);
			btn_equip_compose.setTextFilters(new Array(filter));
			
			
			
			btn_equip_levelup.addActionListener(function():void{FrameHomeEquip.show(_frame.objDest);});
			btn_equip_compose.addActionListener(function():void{FrameHomeEquip.show(_frame.objDest);});
		}

		override public function setImages():void
		{
			super.setImages();
			var img_char_background:DisplayObject = Client.getUIElement("img_home_bg_9") as DisplayObject
			setBackgroundDecorator(new AssetBackground(img_char_background));
			setSize(new IntDimension(img_char_background.width, img_char_background.height));
			setPreferredSize(new IntDimension(img_char_background.width, img_char_background.height));
			setSizeWH(img_char_background.width,img_char_background.height);
			setLocationXY((Engine.W - img_char_background.width) / 2,(Engine.H - img_char_background.height)/2);
			btn_dispatch.addActionListener(function():void{FrameHomeDispatch.show(objDest,_frame);});
			btn_accelerate.addActionListener(function():void{FrameHomeAccelerate.show(_frame);});
		}
		public static var _frame:FrameHomeBuilding9Equip = null;
		public static function show(obj:ObjectHomeBuilding):void
		{
			if(_frame == null)
			{
				_frame = new FrameHomeBuilding9Equip();
				PanelMainHelp.getInstance().addChild(_frame);
			}
			if(!isShowing())
			{
				_frame.show();
				_frame.setLocationXY((Engine.W - _frame.width) / 2,(Engine.H - _frame.height)/2);
				PanelMainHelp.getInstance().bringToTop(_frame);
			}
			_frame.update(obj);
			
		}
		public static function hide():void
		{
			if(isShowing())_frame.hide();
		}
		public static function isShowing():Boolean
		{
			return(_frame != null&& _frame.isShowing());
		}
		public static function update():void
		{
			if(FrameHomeEquip.isShowing())
				FrameHomeEquip._frame.update();
		}
		public static function isShowingEquip():Boolean	
		{
			return FrameHomeEquip.isShowing();
		}
	}
}

import com.*;
import com.Engine.*;
import com.Home.*;
import com.Home.FrameHomeBuilding9Equip;
import com.Packet.*;
import com.UI.*;

import flash.display.*;
import flash.events.*;
import flash.external.*;
import flash.filters.*;
import flash.geom.*;
import flash.system.*;
import flash.text.*;
import flash.ui.*;
import flash.utils.*;

import gs.*;
import gs.easing.*;
import gs.events.TweenEvent;

import org.aswing.*;
import org.aswing.border.*;
import org.aswing.border.EmptyBorder;
import org.aswing.colorchooser.*;
import org.aswing.dnd.*;
import org.aswing.event.*;
import org.aswing.ext.*;
import org.aswing.geom.*;
import org.aswing.tree.AbstractLayoutCache;

class FrameHomeEquip  extends JFrame
{
	
	//members define
	private var panel4:JPanel;
	private var btn_tab_levelup:JToggleButton;
	private var btn_tab_compose:JToggleButton;
	private var panelEquip:JPanel;
	
	private var btn_close:JButton;
	
	private var paneHomeEquipLevelup:PaneHomeEquipLevelup;
	private var paneHomeEquipCompose:PaneHomeEquipCompose;
	
	public function FrameHomeEquip()
	{
		setResizable(false);
		setBorder(new EmptyBorder());
		
		btn_close = new JButton();
		btn_close.setLocation(new IntPoint(198, 0));
		btn_close.setSize(new IntDimension(27, 27));
		btn_close.setPreferredSize(new IntDimension(27, 27));
		this.getTitleBar().setCloseButton(btn_close);
		this.setClipMasked(false);
		getContentPane().setClipMasked(false);
		getTitleBar().getFrame().setClipMasked(false);
		btn_close.setClipMasked(false);
		getTitleBar().setMinimizeHeight(32);
		
		//component creation
		setSize(new IntDimension(442, 448));
		setPreferredSize(new IntDimension(442, 448));
		var layout0:EmptyLayout = new EmptyLayout();
		getContentPane().setLayout(layout0);
		
		panel4 = new JPanel();
		panel4.setLocation(new IntPoint(20, 0));
		panel4.setSize(new IntDimension(422, 28));
		panel4.setPreferredSize(new IntDimension(422, 28));
		var layout1:FlowWrapLayout = new FlowWrapLayout();
		layout1.setPreferWidth(200);
		layout1.setAlignment(AsWingConstants.LEFT);
		layout1.setHgap(2);
		layout1.setVgap(2);
		layout1.setMargin(true);
		panel4.setLayout(layout1);
		
		btn_tab_levelup = new JToggleButton();
		btn_tab_levelup.setLocation(new IntPoint(5, 5));
		btn_tab_levelup.setSize(new IntDimension(57, 25));
		btn_tab_levelup.setPreferredSize(new IntDimension(57, 25));
		btn_tab_levelup.setText("label");
		
		btn_tab_compose = new JToggleButton();
		btn_tab_compose.setLocation(new IntPoint(67, 5));
		btn_tab_compose.setSize(new IntDimension(57, 25));
		btn_tab_compose.setPreferredSize(new IntDimension(57, 25));
		btn_tab_compose.setText("label");
		
		//panelEquip = new JPanel();
		//panelEquip.setLocation(new IntPoint(0, 33));
		//panelEquip.setSize(new IntDimension(442, 381));
		//panelEquip.setPreferredSize(new IntDimension(442, 381));
		
		//component layoution
		//getContentPane().append(panel4);
		//getContentPane().append(panelEquip);
		
		panel4.append(btn_tab_levelup);
		panel4.append(btn_tab_compose);
		
		paneHomeEquipLevelup = new PaneHomeEquipLevelup();
		paneHomeEquipLevelup.setLocation(new IntPoint(0, 30));
		paneHomeEquipLevelup.setSize(new IntDimension(442, 381));
		paneHomeEquipLevelup.setPreferredSize(new IntDimension(442, 381));
		
		paneHomeEquipCompose = new PaneHomeEquipCompose();
		paneHomeEquipCompose.setLocation(new IntPoint(0, 30));
		paneHomeEquipCompose.setSize(new IntDimension(442, 381));
		paneHomeEquipCompose.setPreferredSize(new IntDimension(442, 381));
		
		
		panelEquip = paneHomeEquipLevelup;
		
		//component layoution
		getContentPane().append(panel4);
		getContentPane().append(panelEquip);
		
		setImages();
		addEventListener(AWEvent.SHOWN,FrameHomeBuilding.onSecondFrameShown);
		addEventListener(FrameEvent.FRAME_CLOSING,FrameHomeBuilding.onSecondFrameClosing);
		addEventListener(AWEvent.HIDDEN,FrameHomeBuilding.onSecondFrameClosing);
	}

	private function onTabLevelup(e:Event):void
	{
		if(getBackgroundDecorator() != img_home_equip_levelup_bg)
			setBackgroundDecorator(img_home_equip_levelup_bg);
		if(panelEquip != paneHomeEquipLevelup)
		{
			getContentPane().remove(panelEquip);
			panelEquip = paneHomeEquipLevelup;
			getContentPane().append(panelEquip);
			paneHomeEquipLevelup.update();
		}
		paintImmediately();
	}
	private function onTabCompose(e:Event):void
	{
		if(getBackgroundDecorator() != img_home_equip_compose_bg)
			setBackgroundDecorator(img_home_equip_compose_bg);
		
		if(panelEquip != paneHomeEquipCompose)
		{
			getContentPane().remove(panelEquip);
			panelEquip = paneHomeEquipCompose;
			getContentPane().append(panelEquip);
			paneHomeEquipCompose.update();
		}
		paintImmediately();
	}
	
	private var img_home_equip_levelup_bg:AssetBackground = null;
	private var img_home_equip_compose_bg:AssetBackground = null;
	
	public function setImages():void
	{
		img_home_equip_compose_bg = new AssetBackground(Client.getUIElement("img_home_equip_compose_bg") as DisplayObject);
		
		var img_char_background:DisplayObject = Client.getUIElement("img_home_equip_levelup_bg") as DisplayObject
		img_home_equip_levelup_bg = new AssetBackground(img_char_background);
		setBackgroundDecorator(img_home_equip_levelup_bg);
		setSize(new IntDimension(img_char_background.width, img_char_background.height));
		setPreferredSize(new IntDimension(img_char_background.width, img_char_background.height));
		setSizeWH(img_char_background.width,img_char_background.height);
		setLocationXY((Engine.W - img_char_background.width) / 2,(Engine.H - img_char_background.height)/2);
		
		btn_tab_levelup.wrapSimpleButton(Client.getUIElement("btn_home_tab_levelup") as SimpleButton);
		btn_tab_compose.wrapSimpleButton(Client.getUIElement("btn_home_tab_compose") as SimpleButton);
		
		btn_tab_levelup.setText("");
		btn_tab_compose.setText("");
		
		btn_tab_levelup.addActionListener(onTabLevelup);
		btn_tab_compose.addActionListener(onTabCompose);


		btn_tab_levelup.setSelected(true);
		var groupBagTabs:ButtonGroup = new ButtonGroup();
		groupBagTabs.appendAll(btn_tab_levelup,btn_tab_compose);
		
		btn_close.wrapSimpleButton(Client.getUIElement("btn_close") as SimpleButton);
		
		getContentPane().setClipMasked(false);
		setClipMasked(false);
	}
	public function update():void
	{
		if(panelEquip == paneHomeEquipLevelup)
			paneHomeEquipLevelup.update();
		if(panelEquip == paneHomeEquipCompose)
			paneHomeEquipCompose.update();
	}
	
	public static var _frame:FrameHomeEquip = null;
	public static function show(obj:ObjectHomeBuilding):void
	{
		if(isShowing())
		{
			_frame.hide();
			return;
		}
		if(_frame == null)
		{
			_frame = new FrameHomeEquip();
			PanelMainHelp.getInstance().addChild(_frame);
		}
		
		_frame.show();
		_frame.setLocationXY((Engine.W - _frame.width) / 2,(Engine.H - _frame.height)/2);
		PanelMainHelp.getInstance().bringToTop(_frame);
		
		if(_frame.panelEquip == _frame.paneHomeEquipLevelup)
			_frame.paneHomeEquipLevelup.onShow();
		if(_frame.panelEquip == _frame.paneHomeEquipCompose)
			_frame.paneHomeEquipCompose.onShow();
		
		_frame.update();
		
		var frameHomeBuilding:FrameHomeBuilding = FrameHomeBuilding9Equip._frame;
		
		var teamDestX:int = (Engine.W - (_frame.width+frameHomeBuilding.width))/2;
		var teamDestY:int = (Engine.H - frameHomeBuilding.height)/2;
		
		var listDestX:int = teamDestX + frameHomeBuilding.width;
		var listDestY:int = teamDestY + (frameHomeBuilding.height - _frame.height)/2;
		
		var tween:TweenLite = TweenLite.to(frameHomeBuilding, 0.3, {x:teamDestX, y:teamDestY});
		var list_tween:TweenLite = TweenLite.to(_frame, 0.3, {x:listDestX, y:listDestY});
		
		
		
	}
	public static function hide():void
	{
		if(isShowing())_frame.hide();
	}
	public static function isShowing():Boolean
	{
		return(_frame != null&& _frame.isShowing());
	}
}

/**
 * MyPaneHomeEquipLevelup
 */
class PaneHomeEquipLevelup extends JPanel{
	
	//members define
	private var panelItemEquip:PanelItem;
	private var panelGem0:PanelItem;
	private var panelGem1:PanelItem;
	private var panelGem2:PanelItem;
	private var panel12:JPanel;
	private var btn_home_tab_equip:JToggleButton;
	private var btn_home_tab_bag:JToggleButton;
	private var panelItems:JPanel;
	private var panel33:JPanel;
	private var btn_home_tab_material:JToggleButton;
	private var btn_home_tab_buy:JToggleButton;
	private var panelBottom:JPanel;
	private var panel37:JPanel;
	private var btn_home_equip_levelup:JButton;
	private var multilinelabel39:MultilineLabel;
/**
 * MyPaneHomeEquipLevelup Constructor
 */
	private var paneHomeEquipBottomMaterial:PaneHomeEquipBottomMaterial;
	private var paneHomeEquipBottomBuy:PaneHomeEquipBottomBuy;
	public function PaneHomeEquipLevelup(){
		//component creation
		setSize(new IntDimension(442, 381));
		setPreferredSize(new IntDimension(442, 381));
		var layout0:EmptyLayout = new EmptyLayout();
		setLayout(layout0);
		
		panelItemEquip = new PanelItem();
		panelItemEquip.setLocation(new IntPoint(85, 29));
		panelItemEquip.setSize(new IntDimension(44, 44));
		panelItemEquip.setPreferredSize(new IntDimension(44, 44));
		
		panelGem0 = new PanelItem();
		panelGem0.setLocation(new IntPoint(19, 119));
		panelGem0.setSize(new IntDimension(44, 44));
		panelGem0.setPreferredSize(new IntDimension(44, 44));
		
		panelGem1 = new PanelItem();
		panelGem1.setLocation(new IntPoint(85, 119));
		panelGem1.setSize(new IntDimension(44, 44));
		panelGem1.setPreferredSize(new IntDimension(44, 44));
		
		panelGem2 = new PanelItem();
		panelGem2.setLocation(new IntPoint(151, 119));
		panelGem2.setSize(new IntDimension(44, 44));
		panelGem2.setPreferredSize(new IntDimension(44, 44));
		
		panel12 = new JPanel();
		panel12.setLocation(new IntPoint(207, 0));
		panel12.setSize(new IntDimension(235, 24));
		panel12.setPreferredSize(new IntDimension(235, 24));
		var layout1:FlowWrapLayout = new FlowWrapLayout();
		layout1.setPreferWidth(200);
		layout1.setAlignment(AsWingConstants.LEFT);
		layout1.setHgap(2);
		layout1.setVgap(1);
		layout1.setMargin(true);
		panel12.setLayout(layout1);
		
		btn_home_tab_equip = new JToggleButton();
		btn_home_tab_equip.setLocation(new IntPoint(2, 1));
		btn_home_tab_equip.setSize(new IntDimension(46, 22));
		btn_home_tab_equip.setPreferredSize(new IntDimension(46, 22));
		btn_home_tab_equip.setText("label");
		
		btn_home_tab_bag = new JToggleButton();
		btn_home_tab_bag.setLocation(new IntPoint(35, 1));
		btn_home_tab_bag.setSize(new IntDimension(46, 22));
		btn_home_tab_bag.setPreferredSize(new IntDimension(46, 22));
		btn_home_tab_bag.setText("label");
		
		panelItems = new JPanel();
		panelItems.setLocation(new IntPoint(208, 26));
		panelItems.setSize(new IntDimension(224, 179));
		panelItems.setPreferredSize(new IntDimension(224, 179));
		var layout2:GridLayout = new GridLayout();
		layout2.setRows(4);
		layout2.setColumns(5);
		layout2.setHgap(1);
		layout2.setVgap(1);
		panelItems.setLayout(layout2);
		
		panel33 = new JPanel();
		panel33.setLocation(new IntPoint(207, 208));
		panel33.setSize(new IntDimension(235, 23));
		panel33.setPreferredSize(new IntDimension(235, 23));
		var layout3:FlowWrapLayout = new FlowWrapLayout();
		layout3.setPreferWidth(200);
		layout3.setAlignment(AsWingConstants.LEFT);
		layout3.setHgap(2);
		layout3.setVgap(1);
		layout3.setMargin(true);
		panel33.setLayout(layout3);
		
		btn_home_tab_material = new JToggleButton();
		btn_home_tab_material.setLocation(new IntPoint(5, 5));
		btn_home_tab_material.setSize(new IntDimension(46, 22));
		btn_home_tab_material.setPreferredSize(new IntDimension(46, 22));
		btn_home_tab_material.setText("label");
		
		btn_home_tab_buy = new JToggleButton();
		btn_home_tab_buy.setLocation(new IntPoint(41, 5));
		btn_home_tab_buy.setSize(new IntDimension(46, 22));
		btn_home_tab_buy.setPreferredSize(new IntDimension(46, 22));
		btn_home_tab_buy.setText("label");
		
		panelBottom = new JPanel();
		panelBottom.setLocation(new IntPoint(207, 232));
		panelBottom.setSize(new IntDimension(235, 149));
		panelBottom.setPreferredSize(new IntDimension(235, 149));
		
		panel37 = new JPanel();
		panel37.setLocation(new IntPoint(8, 209));
		panel37.setSize(new IntDimension(198, 23));
		panel37.setPreferredSize(new IntDimension(198, 23));
		var layout4:CenterLayout = new CenterLayout();
		panel37.setLayout(layout4);
		
		btn_home_equip_levelup = new JButton();
		btn_home_equip_levelup.setLocation(new IntPoint(62, 0));
		btn_home_equip_levelup.setSize(new IntDimension(73, 23));
		btn_home_equip_levelup.setPreferredSize(new IntDimension(73, 23));
		btn_home_equip_levelup.setText("label");
		
		multilinelabel39 = new MultilineLabel();
		multilinelabel39.setLocation(new IntPoint(8, 232));
		multilinelabel39.setSize(new IntDimension(198, 141));
		multilinelabel39.setPreferredSize(new IntDimension(198, 141));
		
		//component layoution
		append(panelItemEquip);
		append(panelGem0);
		append(panelGem1);
		append(panelGem2);
		append(panel12);
		append(panelItems);
		append(panel33);
		//append(panelBottom);
		append(panel37);
		append(multilinelabel39);
		
		panel12.append(btn_home_tab_equip);
		panel12.append(btn_home_tab_bag);
		
		panel33.append(btn_home_tab_material);
		panel33.append(btn_home_tab_buy);
		
		panel37.append(btn_home_equip_levelup);
		
		
		//-----------------------------
		paneHomeEquipBottomMaterial = new PaneHomeEquipBottomMaterial();
		paneHomeEquipBottomMaterial.setLocation(new IntPoint(207, 232));
		paneHomeEquipBottomMaterial.setSize(new IntDimension(235, 149));
		paneHomeEquipBottomMaterial.setPreferredSize(new IntDimension(235, 149));
		paneHomeEquipBottomBuy = new PaneHomeEquipBottomBuy();
		paneHomeEquipBottomBuy.setLocation(new IntPoint(207, 232));
		paneHomeEquipBottomBuy.setSize(new IntDimension(235, 149));
		paneHomeEquipBottomBuy.setPreferredSize(new IntDimension(235, 149));
		
		panelBottom = paneHomeEquipBottomMaterial;
		append(panelBottom);
		setImages();
	}
	
	//private var img_home_equip_buy_bg:AssetBackground = null;
	private var _mallItems:Array = [];
	public function setImages():void
	{
		//img_home_equip_buy_bg = new AssetBackground(Client.getUIElement("img_home_equip_buy_bg") as DisplayObject);
		
		panelItemEquip.showBackground = false;
		panelGem0.showBackground = false;
		panelGem1.showBackground = false;
		panelGem2.showBackground = false;
		
		panelItems.setClipMasked(false);
		
		btn_home_tab_equip.wrapSimpleButton(Client.getUIElement("btn_home_tab_equip") as SimpleButton);
		btn_home_tab_bag.wrapSimpleButton(Client.getUIElement("btn_home_tab_bag") as SimpleButton);
		btn_home_tab_material.wrapSimpleButton(Client.getUIElement("btn_home_tab_material") as SimpleButton);
		btn_home_tab_buy.wrapSimpleButton(Client.getUIElement("btn_home_tab_buy") as SimpleButton);
		btn_home_equip_levelup.wrapSimpleButton(Client.getUIElement("btn_home_equip_levelup") as SimpleButton);
		
		btn_home_tab_equip.setText("");
		btn_home_tab_bag.setText("");
		btn_home_tab_material.setText("");
		btn_home_tab_buy.setText("");
		btn_home_equip_levelup.setText("");
		
		btn_home_tab_equip.setSelected(true);
		var groupBagTabs:ButtonGroup = new ButtonGroup();
		groupBagTabs.appendAll(btn_home_tab_equip,btn_home_tab_bag);
		
		btn_home_tab_material.setSelected(true);
		groupBagTabs = new ButtonGroup();
		groupBagTabs.appendAll(btn_home_tab_material,btn_home_tab_buy);
		
		btn_home_tab_material.addActionListener(onTabMaterial);
		btn_home_tab_buy.addActionListener(onTabBuy);
		btn_home_tab_equip.addActionListener(onTabEquip);
		btn_home_tab_bag.addActionListener(onTabBag);
	
		for(var i:int = 0; i < 20; i++)
		{
			var item:PanelItem = new PanelItem;
			item.addEventListener(ClickCountEvent.CLICK_COUNT, onItemEquipClickCount); 
			item.enableClick = false;
			panelItems.append(item);
			_mallItems.push(item);
		}
		for each(var panelItem:PanelItem in paneHomeEquipBottomMaterial._mallItems)
		{
			panelItem.addEventListener(ClickCountEvent.CLICK_COUNT, onItemMaterialClickCount);
		}
		
		panelItemEquip.enableClick = false;
		panelGem0.enableClick = false;
		panelGem1.enableClick = false;
		panelGem2.enableClick = false;
		
		panelItemEquip.addEventListener(ClickCountEvent.CLICK_COUNT, onItemPrepareEquipClickCount);
		panelGem0.addEventListener(ClickCountEvent.CLICK_COUNT, onItemPrepareEquipClickCount);
		panelGem1.addEventListener(ClickCountEvent.CLICK_COUNT, onItemPrepareEquipClickCount);
		panelGem2.addEventListener(ClickCountEvent.CLICK_COUNT, onItemPrepareEquipClickCount);
		
		btn_home_equip_levelup.addActionListener(onBtnEquipLevelup);
		update();
	}
	private function onTabEquip(e:Event):void
	{
		updateEquips();
	}
	private function onTabBag(e:Event):void
	{
		updateEquips();
	}
	private function onBtnEquipLevelup(e:Event):void
	{
		if(panelItemEquip.isEmpty())
		{
			PanelMain.showInfoTimeLimit("请放入装备!");
			return;
		}
		if(panelGem0.isEmpty())
		{
			PanelMain.showInfoTimeLimit("请放入升级石!");
			return;
		}
		Client.getInstance().sendPacketLogic(51,[int(panelItemEquip.item.page),int(panelItemEquip.item.index)
			,int(panelGem0.item.page),int(panelGem0.item.index)
			,int(panelGem1.item == null ? -1 : panelGem1.item.page),int(panelGem1.item == null ? -1 : panelGem1.item.index)
			,int(panelGem2.item == null ? -1 : panelGem2.item.page),int(panelGem2.item == null ? -1 : panelGem2.item.index)]);
		usedItems = [];
		panelItemEquip.item = null;
		panelGem0.item = null;
		panelGem1.item = null;
		panelGem2.item = null;
	}
	
	private function onItemPrepareEquipClickCount(event:ClickCountEvent):void
	{   
		var target:PanelItem = event.target as PanelItem;   
		var index:int = usedItems.indexOf(target.item)
		if(index != -1)
		{
			usedItems.splice(index,1);
		}
		target.item = null;
	} 
	
	private var usedItems:Array = [];
	private function onItemEquipClickCount(event:ClickCountEvent):void
	{   
		var target:PanelItem = event.target as PanelItem;   
		if(usedItems.indexOf(target.item) != -1)
		{
			PanelMain.showInfoTimeLimit("此装备已经放置在目标位置中!");
			return;
		}
		panelItemEquip.item = target.item;
		usedItems.push(target.item);
		
	} 
	private function onItemMaterialClickCount(event:ClickCountEvent):void
	{   
		var target:PanelItem = event.target as PanelItem;  
		if(usedItems.indexOf(target.item) != -1)
		{
			PanelMain.showInfoTimeLimit("此物品已经放置在目标位置中!");
			return;
		}
		if(panelGem0.item == null)
		{
			panelGem0.item = target.item;
			usedItems.push(target.item);
			return;
		}
		if(panelGem1.item == null)
		{
			panelGem1.item = target.item;
			usedItems.push(target.item);
			return;
		}
		if(panelGem2.item == null)
		{
			panelGem2.item = target.item;
			usedItems.push(target.item);
			return;
		}
		
	}
	private function updateMaterials():void
	{
		var arrItems:Array = FrameBag.getItemsByType([Const.ITEM_TYPE_GEM]);
		for(var i:int = 0; i < 15; i++)
		{
			paneHomeEquipBottomMaterial._mallItems[i].item = arrItems[i];
		}
	}
	private function updateEquips():void
	{
		var arrItems:Array = null;
		if(btn_home_tab_equip.isSelected())
			arrItems = FrameBag.getItemsByTypeEquip([Const.ITEM_TYPE_EQUIP]);
		else
			arrItems = FrameBag.getItemsByTypeBag([Const.ITEM_TYPE_EQUIP]);
		for(var i:int = 0; i < 20; i++)
		{
			_mallItems[i].item = arrItems[i];
		}
	}
	public function update():void
	{
		updateEquips();
		updateMaterials();
	}
	public function onShow():void
	{
		usedItems = [];
		panelItemEquip.item = null;
		panelGem0.item = null;
		panelGem1.item = null;
		panelGem2.item = null;
	}
	private function onTabMaterial(e:Event):void
	{
		//if(panelBottom.getBackgroundDecorator() != null)
		//	panelBottom.setBackgroundDecorator(null);
		if(panelBottom != paneHomeEquipBottomMaterial)
		{
			remove(panelBottom);
			panelBottom = paneHomeEquipBottomMaterial;
			append(panelBottom);
		}
		updateMaterials();
		paintImmediately();
	}
	private function onTabBuy(e:Event):void
	{
		//if(panelBottom.getBackgroundDecorator() != img_home_equip_buy_bg)
		//	panelBottom.setBackgroundDecorator(img_home_equip_buy_bg);
		
		if(panelBottom != paneHomeEquipBottomBuy)
		{
			remove(panelBottom);
			panelBottom = paneHomeEquipBottomBuy;
			append(panelBottom);
		}
		paintImmediately();
	}
	}
	
	/**
	 * MyPaneHomeEquipBottomMaterial
	 */
	class PaneHomeEquipBottomMaterial extends JPanel{
		
		//members define
		private var panelItems:JPanel;
		
		/**
		 * MyPaneHomeEquipBottomMaterial Constructor
		 */
		public function PaneHomeEquipBottomMaterial(){
			//component creation
			setLocation(new IntPoint(0, 0));
			setSize(new IntDimension(235, 149));
			setPreferredSize(new IntDimension(235, 149));
			var layout0:EmptyLayout = new EmptyLayout();
			setLayout(layout0);
			
			panelItems = new JPanel();
			panelItems.setLocation(new IntPoint(1, 1));
			panelItems.setSize(new IntDimension(224, 134));
			panelItems.setPreferredSize(new IntDimension(224, 134));
			var layout1:GridLayout = new GridLayout();
			layout1.setRows(3);
			layout1.setColumns(5);
			layout1.setHgap(1);
			layout1.setVgap(1);
			panelItems.setLayout(layout1);
			
			//component layoution
			append(panelItems);
			
			
			for(var i:int = 0; i < 15; i++)
			{
				var item:PanelItem = new PanelItem;
				item.enableClick = false;
				panelItems.append(item);
				_mallItems.push(item);
			}
			
			this.setClipMasked(false);
			panelItems.setClipMasked(false);
		}
		public var _mallItems:Array = [];
		//_________getters_________
		
		
		
	}
	
	/**
	 * MyPaneHomeEquipBottomBuy
	 */
	class PaneHomeEquipBottomBuy extends JPanel{
		
		//members define
		private var labelRefresh:JLabel;
		private var btn_refresh:JButton;
		private var panelItem:PanelItem;
		private var labelName:JLabel;
		private var labelPrice:JLabel;
		private var btn_buy:JButton;
		private var labelDesc:MultilineLabel;
		
		/**
		 * MyPaneHomeEquipBottomBuy Constructor
		 */
		public function PaneHomeEquipBottomBuy(){
			//component creation
			setSize(new IntDimension(235, 149));
			setPreferredSize(new IntDimension(235, 149));
			var layout0:EmptyLayout = new EmptyLayout();
			setLayout(layout0);
			
			labelRefresh = new JLabel();
			labelRefresh.setLocation(new IntPoint(2, 2));
			labelRefresh.setSize(new IntDimension(177, 25));
			labelRefresh.setPreferredSize(new IntDimension(177, 25));
			labelRefresh.setText("label");
			
			btn_refresh = new JButton();
			btn_refresh.setLocation(new IntPoint(179, 3));
			btn_refresh.setSize(new IntDimension(49, 23));
			btn_refresh.setPreferredSize(new IntDimension(49, 23));
			btn_refresh.setText("刷新");
			
			panelItem = new PanelItem();
			panelItem.setLocation(new IntPoint(10, 56));
			panelItem.setSize(new IntDimension(44, 44));
			panelItem.setPreferredSize(new IntDimension(44, 44));
			
			labelName = new JLabel();
			labelName.setLocation(new IntPoint(65, 36));
			labelName.setSize(new IntDimension(170, 20));
			labelName.setPreferredSize(new IntDimension(170, 20));
			labelName.setText("label");
			
			labelPrice = new JLabel();
			labelPrice.setLocation(new IntPoint(97, 69));
			labelPrice.setSize(new IntDimension(81, 16));
			labelPrice.setPreferredSize(new IntDimension(81, 16));
			labelPrice.setText("label");
			
			btn_buy = new JButton();
			btn_buy.setLocation(new IntPoint(179, 65));
			btn_buy.setSize(new IntDimension(49, 23));
			btn_buy.setPreferredSize(new IntDimension(49, 23));
			btn_buy.setText("购买");
			
			labelDesc = new MultilineLabel();
			labelDesc.setLocation(new IntPoint(66, 93));
			labelDesc.setSize(new IntDimension(160, 48));
			labelDesc.setPreferredSize(new IntDimension(160, 48));
			
			//component layoution
			append(labelRefresh);
			append(btn_refresh);
			append(panelItem);
			append(labelName);
			append(labelPrice);
			append(btn_buy);
			append(labelDesc);
			setImages();
		}
		private function setImages():void
		{
			btn_refresh.wrapSimpleButton(Client.getUIElement("btn_2") as SimpleButton);
			btn_buy.wrapSimpleButton(Client.getUIElement("btn_2") as SimpleButton);
			var filter:GlowFilter;
			var font:ASFont = new ASFont("宋体", 14, false, false, false, false);
			filter = new GlowFilter(0x000000, 1, 2, 2, 5);
			btn_refresh.setFont(font);
			btn_refresh.setForeground(ASColor.WHITE);
			btn_refresh.setTextFilters(new Array(filter));
			btn_buy.setFont(font);
			btn_buy.setForeground(ASColor.WHITE);
			btn_buy.setTextFilters(new Array(filter));
			
			font = new ASFont("宋体", 12, false, false, false, false);
			filter = new GlowFilter(0x000000, 1, 2, 2, 10);
			labelRefresh.setForeground(ASColor.WHITE);
			labelRefresh.setFont(font);
			labelRefresh.setTextFilters(new Array(filter));
			labelName.setForeground(ASColor.WHITE);
			labelName.setFont(font);
			labelName.setTextFilters(new Array(filter));
			labelPrice.setForeground(ASColor.WHITE);
			labelPrice.setFont(font);
			labelPrice.setTextFilters(new Array(filter));
			labelDesc.setForeground(ASColor.WHITE);
			labelDesc.setFont(font);
			labelDesc.filters = (new Array(filter));
			
			setBackgroundDecorator(new AssetBackground(Client.getUIElement("img_home_equip_buy_bg") as DisplayObject));
		}
		
		
	}
	/**
	 * MyPaneHomeEquipLevelup
	 */
	//class PaneHomeEquipCompose extends JPanel{
		
/**
 * MyPaneHomeEquipLevelup
 */
class PaneHomeEquipCompose extends JPanel{
	
	//members define
	private var panelItemEquip:PanelItem;
	private var panelGem0:PanelItem;
	private var panelGem1:PanelItem;
	private var panelGem2:PanelItem;
	private var panel12:JPanel;
	private var btn_home_tab_equip:JToggleButton;
	private var btn_home_tab_bag:JToggleButton;
	private var panelItems:JPanel;
	private var panel33:JPanel;
	private var btn_home_tab_material:JToggleButton;
	private var btn_home_tab_buy:JToggleButton;
	private var panelBottom:JPanel;
	private var panel37:JPanel;
	private var btn_home_equip_compose:JButton;
	private var multilinelabel39:MultilineLabel;
	/**
	 * MyPaneHomeEquipLevelup Constructor
	 */
	private var paneHomeEquipBottomMaterial:PaneHomeEquipBottomMaterial;
	private var paneHomeEquipBottomBuy:PaneHomeEquipBottomBuy;
	public function PaneHomeEquipCompose(){
		//component creation
		setSize(new IntDimension(442, 381));
		setPreferredSize(new IntDimension(442, 381));
		var layout0:EmptyLayout = new EmptyLayout();
		setLayout(layout0);
		
		panelItemEquip = new PanelItem();
		panelItemEquip.setLocation(new IntPoint(85, 29));
		panelItemEquip.setSize(new IntDimension(44, 44));
		panelItemEquip.setPreferredSize(new IntDimension(44, 44));
		
		panelGem0 = new PanelItem();
		panelGem0.setLocation(new IntPoint(19, 119));
		panelGem0.setSize(new IntDimension(44, 44));
		panelGem0.setPreferredSize(new IntDimension(44, 44));
		
		panelGem1 = new PanelItem();
		panelGem1.setLocation(new IntPoint(85, 119));
		panelGem1.setSize(new IntDimension(44, 44));
		panelGem1.setPreferredSize(new IntDimension(44, 44));
		
		panelGem2 = new PanelItem();
		panelGem2.setLocation(new IntPoint(151, 119));
		panelGem2.setSize(new IntDimension(44, 44));
		panelGem2.setPreferredSize(new IntDimension(44, 44));
		
		panel12 = new JPanel();
		panel12.setLocation(new IntPoint(207, 0));
		panel12.setSize(new IntDimension(235, 24));
		panel12.setPreferredSize(new IntDimension(235, 24));
		var layout1:FlowWrapLayout = new FlowWrapLayout();
		layout1.setPreferWidth(200);
		layout1.setAlignment(AsWingConstants.LEFT);
		layout1.setHgap(2);
		layout1.setVgap(1);
		layout1.setMargin(true);
		panel12.setLayout(layout1);
		
		btn_home_tab_equip = new JToggleButton();
		btn_home_tab_equip.setLocation(new IntPoint(2, 1));
		btn_home_tab_equip.setSize(new IntDimension(46, 22));
		btn_home_tab_equip.setPreferredSize(new IntDimension(46, 22));
		btn_home_tab_equip.setText("label");
		
		btn_home_tab_bag = new JToggleButton();
		btn_home_tab_bag.setLocation(new IntPoint(35, 1));
		btn_home_tab_bag.setSize(new IntDimension(46, 22));
		btn_home_tab_bag.setPreferredSize(new IntDimension(46, 22));
		btn_home_tab_bag.setText("label");
		
		panelItems = new JPanel();
		panelItems.setLocation(new IntPoint(208, 26));
		panelItems.setSize(new IntDimension(224, 179));
		panelItems.setPreferredSize(new IntDimension(224, 179));
		var layout2:GridLayout = new GridLayout();
		layout2.setRows(4);
		layout2.setColumns(5);
		layout2.setHgap(1);
		layout2.setVgap(1);
		panelItems.setLayout(layout2);
		
		panel33 = new JPanel();
		panel33.setLocation(new IntPoint(207, 208));
		panel33.setSize(new IntDimension(235, 23));
		panel33.setPreferredSize(new IntDimension(235, 23));
		var layout3:FlowWrapLayout = new FlowWrapLayout();
		layout3.setPreferWidth(200);
		layout3.setAlignment(AsWingConstants.LEFT);
		layout3.setHgap(2);
		layout3.setVgap(1);
		layout3.setMargin(true);
		panel33.setLayout(layout3);
		
		btn_home_tab_material = new JToggleButton();
		btn_home_tab_material.setLocation(new IntPoint(5, 5));
		btn_home_tab_material.setSize(new IntDimension(46, 22));
		btn_home_tab_material.setPreferredSize(new IntDimension(46, 22));
		btn_home_tab_material.setText("label");
		
		btn_home_tab_buy = new JToggleButton();
		btn_home_tab_buy.setLocation(new IntPoint(41, 5));
		btn_home_tab_buy.setSize(new IntDimension(46, 22));
		btn_home_tab_buy.setPreferredSize(new IntDimension(46, 22));
		btn_home_tab_buy.setText("label");
		
		panelBottom = new JPanel();
		panelBottom.setLocation(new IntPoint(207, 232));
		panelBottom.setSize(new IntDimension(235, 149));
		panelBottom.setPreferredSize(new IntDimension(235, 149));
		
		panel37 = new JPanel();
		panel37.setLocation(new IntPoint(8, 209));
		panel37.setSize(new IntDimension(198, 23));
		panel37.setPreferredSize(new IntDimension(198, 23));
		var layout4:CenterLayout = new CenterLayout();
		panel37.setLayout(layout4);
		
		btn_home_equip_compose = new JButton();
		btn_home_equip_compose.setLocation(new IntPoint(62, 0));
		btn_home_equip_compose.setSize(new IntDimension(73, 23));
		btn_home_equip_compose.setPreferredSize(new IntDimension(73, 23));
		btn_home_equip_compose.setText("label");
		
		multilinelabel39 = new MultilineLabel();
		multilinelabel39.setLocation(new IntPoint(8, 232));
		multilinelabel39.setSize(new IntDimension(198, 141));
		multilinelabel39.setPreferredSize(new IntDimension(198, 141));
		
		//component layoution
		append(panelItemEquip);
		append(panelGem0);
		append(panelGem1);
		append(panelGem2);
		append(panel12);
		append(panelItems);
		append(panel33);
		//append(panelBottom);
		append(panel37);
		append(multilinelabel39);
		
		panel12.append(btn_home_tab_equip);
		panel12.append(btn_home_tab_bag);
		
		panel33.append(btn_home_tab_material);
		panel33.append(btn_home_tab_buy);
		
		panel37.append(btn_home_equip_compose);
		
		
		//-----------------------------
		paneHomeEquipBottomMaterial = new PaneHomeEquipBottomMaterial();
		paneHomeEquipBottomMaterial.setLocation(new IntPoint(207, 232));
		paneHomeEquipBottomMaterial.setSize(new IntDimension(235, 149));
		paneHomeEquipBottomMaterial.setPreferredSize(new IntDimension(235, 149));
		paneHomeEquipBottomBuy = new PaneHomeEquipBottomBuy();
		paneHomeEquipBottomBuy.setLocation(new IntPoint(207, 232));
		paneHomeEquipBottomBuy.setSize(new IntDimension(235, 149));
		paneHomeEquipBottomBuy.setPreferredSize(new IntDimension(235, 149));
		
		panelBottom = paneHomeEquipBottomMaterial;
		append(panelBottom);
		setImages();
	}
	
	//private var img_home_equip_buy_bg:AssetBackground = null;
	private var _mallItems:Array = [];
	public function setImages():void
	{
		//img_home_equip_buy_bg = new AssetBackground(Client.getUIElement("img_home_equip_buy_bg") as DisplayObject);
		
		panelItemEquip.showBackground = false;
		panelGem0.showBackground = false;
		panelGem1.showBackground = false;
		panelGem2.showBackground = false;
		
		panelItems.setClipMasked(false);
		
		btn_home_tab_equip.wrapSimpleButton(Client.getUIElement("btn_home_tab_equip") as SimpleButton);
		btn_home_tab_bag.wrapSimpleButton(Client.getUIElement("btn_home_tab_bag") as SimpleButton);
		btn_home_tab_material.wrapSimpleButton(Client.getUIElement("btn_home_tab_material") as SimpleButton);
		btn_home_tab_buy.wrapSimpleButton(Client.getUIElement("btn_home_tab_buy") as SimpleButton);
		btn_home_equip_compose.wrapSimpleButton(Client.getUIElement("btn_home_equip_compose") as SimpleButton);
		//btn_home_equip_compose.wrapSimpleButton(Client.getUIElement("btn_4") as SimpleButton);
		
		btn_home_tab_equip.setText("");
		btn_home_tab_bag.setText("");
		btn_home_tab_material.setText("");
		btn_home_tab_buy.setText("");
		btn_home_equip_compose.setText("");
		
		btn_home_tab_bag.setSelected(true);
		btn_home_tab_equip.setVisible(false);
		var groupBagTabs:ButtonGroup = new ButtonGroup();
		groupBagTabs.appendAll(btn_home_tab_equip,btn_home_tab_bag);
		
		btn_home_tab_material.setSelected(true);
		groupBagTabs = new ButtonGroup();
		groupBagTabs.appendAll(btn_home_tab_material,btn_home_tab_buy);
		
		btn_home_tab_material.addActionListener(onTabMaterial);
		btn_home_tab_buy.addActionListener(onTabBuy);
		btn_home_tab_equip.addActionListener(onTabEquip);
		btn_home_tab_bag.addActionListener(onTabBag);
		
		for(var i:int = 0; i < 20; i++)
		{
			var item:PanelItem = new PanelItem;
			item.addEventListener(ClickCountEvent.CLICK_COUNT, onItemEquipClickCount); 
			item.enableClick = false;
			panelItems.append(item);
			_mallItems.push(item);
		}
		for each(var panelItem:PanelItem in paneHomeEquipBottomMaterial._mallItems)
		{
			panelItem.addEventListener(ClickCountEvent.CLICK_COUNT, onItemMaterialClickCount);
		}
		
		panelItemEquip.enableClick = false;
		panelGem0.enableClick = false;
		panelGem1.enableClick = false;
		panelGem2.enableClick = false;
		
		panelItemEquip.addEventListener(ClickCountEvent.CLICK_COUNT, onItemPrepareEquipClickCount);
		panelGem0.addEventListener(ClickCountEvent.CLICK_COUNT, onItemPrepareEquipClickCount);
		panelGem1.addEventListener(ClickCountEvent.CLICK_COUNT, onItemPrepareEquipClickCount);
		panelGem2.addEventListener(ClickCountEvent.CLICK_COUNT, onItemPrepareEquipClickCount);
		
		btn_home_equip_compose.addActionListener(onBtnEquipCompose);
		update();
	}
	private function onTabEquip(e:Event):void
	{
		updateEquips();
	}
	private function onTabBag(e:Event):void
	{
		updateEquips();
	}
	private function onBtnEquipCompose(e:Event):void
	{
		if(panelItemEquip.isEmpty())
		{
			PanelMain.showInfoTimeLimit("请放入装备!");
			return;
		}
		if(panelGem0.isEmpty() || panelGem1.isEmpty() || panelGem2.isEmpty())
		{
			PanelMain.showInfoTimeLimit("请放入材料!");
			return;
		}
		Client.getInstance().sendPacketLogic(52,[int(panelItemEquip.item.page),int(panelItemEquip.item.index)
			,int(panelGem0.item.page),int(panelGem0.item.index)
			,int(panelGem1.item == null ? -1 : panelGem1.item.page),int(panelGem1.item == null ? -1 : panelGem1.item.index)
			,int(panelGem2.item == null ? -1 : panelGem2.item.page),int(panelGem2.item == null ? -1 : panelGem2.item.index)]);
		usedItems = [];
		panelItemEquip.item = null;
		panelGem0.item = null;
		panelGem1.item = null;
		panelGem2.item = null;
	}
	
	private function onItemPrepareEquipClickCount(event:ClickCountEvent):void
	{   
		var target:PanelItem = event.target as PanelItem;   
		var index:int = usedItems.indexOf(target.item)
		if(index != -1)
		{
			usedItems.splice(index,1);
		}
		target.item = null;
	} 
	
	private var usedItems:Array = [];
	private function onItemEquipClickCount(event:ClickCountEvent):void
	{   
		var target:PanelItem = event.target as PanelItem;   
		if(usedItems.indexOf(target.item) != -1)
		{
			PanelMain.showInfoTimeLimit("此装备已经放置在目标位置中!");
			return;
		}
		panelItemEquip.item = target.item;
		usedItems.push(target.item);
		
	} 
	private function onItemMaterialClickCount(event:ClickCountEvent):void
	{   
		var target:PanelItem = event.target as PanelItem;  
		if(usedItems.indexOf(target.item) != -1)
		{
			PanelMain.showInfoTimeLimit("此物品已经放置在目标位置中!");
			return;
		}
		if(panelGem0.item == null)
		{
			panelGem0.item = target.item;
			usedItems.push(target.item);
			return;
		}
		if(panelGem1.item == null)
		{
			panelGem1.item = target.item;
			usedItems.push(target.item);
			return;
		}
		if(panelGem2.item == null)
		{
			panelGem2.item = target.item;
			usedItems.push(target.item);
			return;
		}
		
	}
	private function updateMaterials():void
	{
		var arrItems:Array = FrameBag.getItemsByType([Const.ITEM_TYPE_MATERIAL]);
		for(var i:int = 0; i < 15; i++)
		{
			paneHomeEquipBottomMaterial._mallItems[i].item = arrItems[i];
		}
	}
	private function updateEquips():void
	{
		var arrItems:Array = null;
		//if(btn_home_tab_equip.isSelected())
		//	arrItems = FrameBag.getItemsByTypeEquip([Const.ITEM_TYPE_EQUIP]);
		//else
			arrItems = FrameBag.getItemsByTypeBag([Const.ITEM_TYPE_ATLAS]);
		for(var i:int = 0; i < 20; i++)
		{
			_mallItems[i].item = arrItems[i];
		}
	}
	public function update():void
	{
		updateEquips();
		updateMaterials();
	}
	public function onShow():void
	{
		usedItems = [];
		panelItemEquip.item = null;
		panelGem0.item = null;
		panelGem1.item = null;
		panelGem2.item = null;
	}
	private function onTabMaterial(e:Event):void
	{
		//if(panelBottom.getBackgroundDecorator() != null)
		//	panelBottom.setBackgroundDecorator(null);
		if(panelBottom != paneHomeEquipBottomMaterial)
		{
			remove(panelBottom);
			panelBottom = paneHomeEquipBottomMaterial;
			append(panelBottom);
		}
		updateMaterials();
		paintImmediately();
	}
	private function onTabBuy(e:Event):void
	{
		//if(panelBottom.getBackgroundDecorator() != img_home_equip_buy_bg)
		//	panelBottom.setBackgroundDecorator(img_home_equip_buy_bg);
		
		if(panelBottom != paneHomeEquipBottomBuy)
		{
			remove(panelBottom);
			panelBottom = paneHomeEquipBottomBuy;
			append(panelBottom);
		}
		paintImmediately();
	}
}